#ifndef _GAMESTATE_H_
#define _GAMESTATE_H_

#include <SFML/Graphics.hpp>

class Game;


///////////////////////////////////////////////////////
/// \brief Abstract class representing a game state.
///
/// A game state is a state in which the game can be
/// at a given time.
///
/// \note Singleton class
///
///////////////////////////////////////////////////////
class GameState
{
public:
    ///////////////////////////////////////////////////////
    /// \brief Initializes the state.
    ///
    ///////////////////////////////////////////////////////
    virtual void init() = 0;

    ///////////////////////////////////////////////////////
    /// \brief Resets the state.
    ///
    ///////////////////////////////////////////////////////
    virtual void reset() = 0;

    ///////////////////////////////////////////////////////
    /// \brief Handles the events of the game.
    ///
    ///////////////////////////////////////////////////////
    virtual void handleEvents() = 0;

    ///////////////////////////////////////////////////////
    /// \brief Updates the content of the game.
    ///
    ///////////////////////////////////////////////////////
    virtual void update() = 0;

    ///////////////////////////////////////////////////////
    /// \brief Renders the content of the game.
    ///
    ///////////////////////////////////////////////////////
    virtual void render() = 0;

protected:
    ///////////////////////////////////////////////////////
    /// \brief Create the state from the gane and its
    ///        rendering window.
    ///
    /// \param game  Game the state must act on.
    /// \param window Window used to render the game.
    ///
    ///////////////////////////////////////////////////////
    GameState(Game* game, sf::RenderWindow* window);

    ///////////////////////////////////////////////////////
    /// \brief Destructor
    ///
    ///////////////////////////////////////////////////////
    virtual ~GameState();

    ///////////////////////////////////////////////////////
    /// \brief Disabled default constructor
    ///
    ///////////////////////////////////////////////////////
    GameState() = delete;

    ///////////////////////////////////////////////////////
    /// \brief Disabled copy constructor
    ///
    ///////////////////////////////////////////////////////
    GameState(const GameState& ) = delete;

    ///////////////////////////////////////////////////////
    /// \brief Disabled assignment operator
    ///
    ///////////////////////////////////////////////////////
    GameState& operator=(const GameState& ) = delete;

    ///////////////////////////////////////////////////////
    /// \brief Loads the textures required for this state
    ///        of the game.
    ///
    ///////////////////////////////////////////////////////
    virtual void loadTextures() const = 0;

    ///////////////////////////////////////////////////////
    /// \brief Loads a texture from a file and give it to
    ///        the resource manager.
    ///
    /// Throws an exception if a texture cannot be loaded.
    ///
    /// \param texture Texture in which the image will be loaded.
    /// \param fileName Name of the texture to load.
    /// \param textureName Name of the texture for the resource manager
    ///
    ///////////////////////////////////////////////////////
    virtual void loadTexture(sf::Texture* texture,
                             const std::string& fileName,
                             const std::string& textureName) const = 0;

    ///////////////////////////////////////////////////////
    /// \brief Loads the sprites required for this state
    ///        of the game.
    ///
    ///////////////////////////////////////////////////////
    virtual void loadSprites() const = 0;

    Game* game_;  ///< The game the state must act on
    sf::RenderWindow* window_;  ///< The window where the game is being rendered
};


#endif /* _GAMESTATE_H_ */
